package com.jolink.omiis.wechat.message.type;

import com.jolink.omiis.wechat.message.bean.request.ImageMessageRequest;
import com.jolink.omiis.wechat.message.bean.request.LocationMessageRequest;
import com.jolink.omiis.wechat.message.bean.request.TextMessageRequest;
import com.jolink.omiis.wechat.message.bean.request.VideoMessageRequest;
import com.jolink.omiis.wechat.message.bean.request.VoiceMessageRequest;

/**
 * 
 * 消息类型
 * 
 * @author WangYanqing
 *
 */
public enum MessageType {

	TEXT("text"), VIDEO("video"), SHORTVIDEO("shortvideo"), IMAGE("image"), VOICE("voice"), AUDIO("audio"), LOCATION(
			"location"), LINK("link"), EVENT("event"), NEWS("news"), MUSIC("music");

	private String value;

	MessageType(String value) {
		this.value = value;
	}

	public String getValue() {
		return value;
	}

	@SuppressWarnings({ "rawtypes", "unused" })
	public Class getBaseMessageRequest() {
		Class clazz = TextMessageRequest.class;
		switch (valueOf(value.toUpperCase())) {
		case TEXT:
			clazz = TextMessageRequest.class;
			break;
		case IMAGE:
			clazz = ImageMessageRequest.class;
			break;
		case VOICE:
			AUDIO: clazz = VoiceMessageRequest.class;
			break;
		case VIDEO:
			clazz = VideoMessageRequest.class;
			break;
		case LOCATION:
			clazz = LocationMessageRequest.class;
			break;
		default:
			break;
		}
		if (clazz == null) {
			throw new RuntimeException("不支持的消息类型：" + value.toUpperCase());
		}
		return clazz;
	}
}
